/*******************************************************************************
 *
 *    Copyright (c) Baina Info Tech Co. Ltd
 *
 *    My_Ringtone
 *    
 *    RingtoneTypeDialog
 *    TODO File description or class description.
 *
 *    @author: zuochen
 *    @since:  2011-1-20
 *    @version: 1.0
 *
 ******************************************************************************/

package com.tools.ringtone.view;

import android.app.Dialog;
import android.content.Context;
import android.media.RingtoneManager;
import android.net.Uri;
import android.view.View;
import android.view.Window;

import com.mp3.dwonloader.ringtonemaker.musicradio.zl.R;
import com.tools.ringtone.util.RingtoneMangerUtil;

/**
 * RingtoneTypeDialog of My_Ringtone.
 * 
 * @author zuochen
 * 
 */

public class RingtoneTypeDialog extends Dialog implements
		android.view.View.OnClickListener {
	private final Context mContext;
	private final Uri mUri;

	/**
	 * Initiate a new instance of {@link RingtoneTypeDialog}.
	 * 
	 * @param context
	 */
	public RingtoneTypeDialog(Context context, Uri aUri) {
		super(context);
		this.mContext = context;
		this.mUri = aUri;
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.ringtone_type_dialog);
		findViewById(R.id.button_play).setOnClickListener(this);
		findViewById(R.id.button_set_as).setOnClickListener(this);
		findViewById(R.id.button_edit).setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.button_play:
			RingtoneMangerUtil.setRingtone(mContext,
					RingtoneManager.TYPE_RINGTONE, mUri);
			break;
		case R.id.button_set_as:
			RingtoneMangerUtil.setRingtone(mContext,
					RingtoneManager.TYPE_NOTIFICATION, mUri);
			break;
		case R.id.button_edit:
			RingtoneMangerUtil.setRingtone(mContext,
					RingtoneManager.TYPE_ALARM, mUri);
			break;
		}
		dismiss();
	}

}
